﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Maticsoft.DBUtility;//Please add references
namespace ElingOA6_DSJCJ.DAL
{
	/// <summary>
	/// 数据访问类:Entity
	/// </summary>
	public partial class Entity
	{
		public Entity()
		{}
		#region  Method

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string FEntityNo)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from t_Entity");
			strSql.Append(" where FEntityNo=@FEntityNo ");
			SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12)			};
			parameters[0].Value = FEntityNo;

			return DbHelperSQL.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(ElingOA6_DSJCJ.Model.Entity model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into t_Entity(");
			strSql.Append("FEntityNo,FEntityName,FLeader,FShortName,FAccessDate,FLastLoginIPAddr,FLogID,fuseTimes,FPublishRoot,FWaterMarkContent,FWaterMarkSvrFileName,FWaterMarkExt,FWaterMarkOldFileName,FWebBeiAnNo,FCopyRight,FTxtWaterMark,FSmtpHost,FSmtpAccount,FSmtpPassword,FWaterMarkCls,FSmtpPort,FIsSsl,FFlowLockTime,FIsIPControl,FNTKOCaption,FNTKOKey,FSysCopyRight,FSysTitle)");
			strSql.Append(" values (");
			strSql.Append("@FEntityNo,@FEntityName,@FLeader,@FShortName,@FAccessDate,@FLastLoginIPAddr,@FLogID,@fuseTimes,@FPublishRoot,@FWaterMarkContent,@FWaterMarkSvrFileName,@FWaterMarkExt,@FWaterMarkOldFileName,@FWebBeiAnNo,@FCopyRight,@FTxtWaterMark,@FSmtpHost,@FSmtpAccount,@FSmtpPassword,@FWaterMarkCls,@FSmtpPort,@FIsSsl,@FFlowLockTime,@FIsIPControl,@FNTKOCaption,@FNTKOKey,@FSysCopyRight,@FSysTitle)");
			SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
					new SqlParameter("@FEntityName", SqlDbType.NVarChar,50),
					new SqlParameter("@FLeader", SqlDbType.NVarChar,10),
					new SqlParameter("@FShortName", SqlDbType.NVarChar,20),
					new SqlParameter("@FAccessDate", SqlDbType.DateTime),
					new SqlParameter("@FLastLoginIPAddr", SqlDbType.VarChar,15),
					new SqlParameter("@FLogID", SqlDbType.NVarChar,30),
					new SqlParameter("@fuseTimes", SqlDbType.Int,4),
					new SqlParameter("@FPublishRoot", SqlDbType.NVarChar,255),
					new SqlParameter("@FWaterMarkContent", SqlDbType.Image),
					new SqlParameter("@FWaterMarkSvrFileName", SqlDbType.NVarChar,255),
					new SqlParameter("@FWaterMarkExt", SqlDbType.NVarChar,80),
					new SqlParameter("@FWaterMarkOldFileName", SqlDbType.NVarChar,255),
					new SqlParameter("@FWebBeiAnNo", SqlDbType.NVarChar,255),
					new SqlParameter("@FCopyRight", SqlDbType.NText),
					new SqlParameter("@FTxtWaterMark", SqlDbType.NVarChar,20),
					new SqlParameter("@FSmtpHost", SqlDbType.NVarChar,80),
					new SqlParameter("@FSmtpAccount", SqlDbType.NVarChar,80),
					new SqlParameter("@FSmtpPassword", SqlDbType.NVarChar,30),
					new SqlParameter("@FWaterMarkCls", SqlDbType.NChar,1),
					new SqlParameter("@FSmtpPort", SqlDbType.Int,4),
					new SqlParameter("@FIsSsl", SqlDbType.Decimal,5),
					new SqlParameter("@FFlowLockTime", SqlDbType.Int,4),
					new SqlParameter("@FIsIPControl", SqlDbType.NChar,1),
					new SqlParameter("@FNTKOCaption", SqlDbType.NVarChar,30),
					new SqlParameter("@FNTKOKey", SqlDbType.NVarChar,50),
					new SqlParameter("@FSysCopyRight", SqlDbType.NVarChar,80),
					new SqlParameter("@FSysTitle", SqlDbType.NVarChar,200)};
			parameters[0].Value = model.FEntityNo;
			parameters[1].Value = model.FEntityName;
			parameters[2].Value = model.FLeader;
			parameters[3].Value = model.FShortName;
			parameters[4].Value = model.FAccessDate;
			parameters[5].Value = model.FLastLoginIPAddr;
			parameters[6].Value = model.FLogID;
			parameters[7].Value = model.fuseTimes;
			parameters[8].Value = model.FPublishRoot;
			parameters[9].Value = model.FWaterMarkContent;
			parameters[10].Value = model.FWaterMarkSvrFileName;
			parameters[11].Value = model.FWaterMarkExt;
			parameters[12].Value = model.FWaterMarkOldFileName;
			parameters[13].Value = model.FWebBeiAnNo;
			parameters[14].Value = model.FCopyRight;
			parameters[15].Value = model.FTxtWaterMark;
			parameters[16].Value = model.FSmtpHost;
			parameters[17].Value = model.FSmtpAccount;
			parameters[18].Value = model.FSmtpPassword;
			parameters[19].Value = model.FWaterMarkCls;
			parameters[20].Value = model.FSmtpPort;
			parameters[21].Value = model.FIsSsl;
			parameters[22].Value = model.FFlowLockTime;
			parameters[23].Value = model.FIsIPControl;
			parameters[24].Value = model.FNTKOCaption;
			parameters[25].Value = model.FNTKOKey;
			parameters[26].Value = model.FSysCopyRight;
			parameters[27].Value = model.FSysTitle;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(ElingOA6_DSJCJ.Model.Entity model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update t_Entity set ");
			strSql.Append("FEntityName=@FEntityName,");
			strSql.Append("FLeader=@FLeader,");
			strSql.Append("FShortName=@FShortName,");
			strSql.Append("FAccessDate=@FAccessDate,");
			strSql.Append("FLastLoginIPAddr=@FLastLoginIPAddr,");
			strSql.Append("FLogID=@FLogID,");
			strSql.Append("fuseTimes=@fuseTimes,");
			strSql.Append("FPublishRoot=@FPublishRoot,");
			strSql.Append("FWaterMarkContent=@FWaterMarkContent,");
			strSql.Append("FWaterMarkSvrFileName=@FWaterMarkSvrFileName,");
			strSql.Append("FWaterMarkExt=@FWaterMarkExt,");
			strSql.Append("FWaterMarkOldFileName=@FWaterMarkOldFileName,");
			strSql.Append("FWebBeiAnNo=@FWebBeiAnNo,");
			strSql.Append("FCopyRight=@FCopyRight,");
			strSql.Append("FTxtWaterMark=@FTxtWaterMark,");
			strSql.Append("FSmtpHost=@FSmtpHost,");
			strSql.Append("FSmtpAccount=@FSmtpAccount,");
			strSql.Append("FSmtpPassword=@FSmtpPassword,");
			strSql.Append("FWaterMarkCls=@FWaterMarkCls,");
			strSql.Append("FSmtpPort=@FSmtpPort,");
			strSql.Append("FIsSsl=@FIsSsl,");
			strSql.Append("FFlowLockTime=@FFlowLockTime,");
			strSql.Append("FIsIPControl=@FIsIPControl,");
			strSql.Append("FNTKOCaption=@FNTKOCaption,");
			strSql.Append("FNTKOKey=@FNTKOKey,");
			strSql.Append("FSysCopyRight=@FSysCopyRight,");
			strSql.Append("FSysTitle=@FSysTitle");
			strSql.Append(" where FEntityNo=@FEntityNo ");
			SqlParameter[] parameters = {
					new SqlParameter("@FEntityName", SqlDbType.NVarChar,50),
					new SqlParameter("@FLeader", SqlDbType.NVarChar,10),
					new SqlParameter("@FShortName", SqlDbType.NVarChar,20),
					new SqlParameter("@FAccessDate", SqlDbType.DateTime),
					new SqlParameter("@FLastLoginIPAddr", SqlDbType.VarChar,15),
					new SqlParameter("@FLogID", SqlDbType.NVarChar,30),
					new SqlParameter("@fuseTimes", SqlDbType.Int,4),
					new SqlParameter("@FPublishRoot", SqlDbType.NVarChar,255),
					new SqlParameter("@FWaterMarkContent", SqlDbType.Image),
					new SqlParameter("@FWaterMarkSvrFileName", SqlDbType.NVarChar,255),
					new SqlParameter("@FWaterMarkExt", SqlDbType.NVarChar,80),
					new SqlParameter("@FWaterMarkOldFileName", SqlDbType.NVarChar,255),
					new SqlParameter("@FWebBeiAnNo", SqlDbType.NVarChar,255),
					new SqlParameter("@FCopyRight", SqlDbType.NText),
					new SqlParameter("@FTxtWaterMark", SqlDbType.NVarChar,20),
					new SqlParameter("@FSmtpHost", SqlDbType.NVarChar,80),
					new SqlParameter("@FSmtpAccount", SqlDbType.NVarChar,80),
					new SqlParameter("@FSmtpPassword", SqlDbType.NVarChar,30),
					new SqlParameter("@FWaterMarkCls", SqlDbType.NChar,1),
					new SqlParameter("@FSmtpPort", SqlDbType.Int,4),
					new SqlParameter("@FIsSsl", SqlDbType.Decimal,5),
					new SqlParameter("@FFlowLockTime", SqlDbType.Int,4),
					new SqlParameter("@FIsIPControl", SqlDbType.NChar,1),
					new SqlParameter("@FNTKOCaption", SqlDbType.NVarChar,30),
					new SqlParameter("@FNTKOKey", SqlDbType.NVarChar,50),
					new SqlParameter("@FSysCopyRight", SqlDbType.NVarChar,80),
					new SqlParameter("@FSysTitle", SqlDbType.NVarChar,200),
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12)};
			parameters[0].Value = model.FEntityName;
			parameters[1].Value = model.FLeader;
			parameters[2].Value = model.FShortName;
			parameters[3].Value = model.FAccessDate;
			parameters[4].Value = model.FLastLoginIPAddr;
			parameters[5].Value = model.FLogID;
			parameters[6].Value = model.fuseTimes;
			parameters[7].Value = model.FPublishRoot;
			parameters[8].Value = model.FWaterMarkContent;
			parameters[9].Value = model.FWaterMarkSvrFileName;
			parameters[10].Value = model.FWaterMarkExt;
			parameters[11].Value = model.FWaterMarkOldFileName;
			parameters[12].Value = model.FWebBeiAnNo;
			parameters[13].Value = model.FCopyRight;
			parameters[14].Value = model.FTxtWaterMark;
			parameters[15].Value = model.FSmtpHost;
			parameters[16].Value = model.FSmtpAccount;
			parameters[17].Value = model.FSmtpPassword;
			parameters[18].Value = model.FWaterMarkCls;
			parameters[19].Value = model.FSmtpPort;
			parameters[20].Value = model.FIsSsl;
			parameters[21].Value = model.FFlowLockTime;
			parameters[22].Value = model.FIsIPControl;
			parameters[23].Value = model.FNTKOCaption;
			parameters[24].Value = model.FNTKOKey;
			parameters[25].Value = model.FSysCopyRight;
			parameters[26].Value = model.FSysTitle;
			parameters[27].Value = model.FEntityNo;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(string FEntityNo)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from t_Entity ");
			strSql.Append(" where FEntityNo=@FEntityNo ");
			SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12)			};
			parameters[0].Value = FEntityNo;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 批量删除数据
		/// </summary>
		public bool DeleteList(string FEntityNolist )
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from t_Entity ");
			strSql.Append(" where FEntityNo in ("+FEntityNolist + ")  ");
			int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ElingOA6_DSJCJ.Model.Entity GetModel(string FEntityNo)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 FEntityNo,FEntityName,FLeader,FShortName,FAccessDate,FLastLoginIPAddr,FLogID,fuseTimes,FPublishRoot,FWaterMarkContent,FWaterMarkSvrFileName,FWaterMarkExt,FWaterMarkOldFileName,FWebBeiAnNo,FCopyRight,FTxtWaterMark,FSmtpHost,FSmtpAccount,FSmtpPassword,FWaterMarkCls,FSmtpPort,FIsSsl,FFlowLockTime,FIsIPControl,FNTKOCaption,FNTKOKey,FSysCopyRight,FSysTitle from t_Entity ");
			strSql.Append(" where FEntityNo=@FEntityNo ");
			SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12)			};
			parameters[0].Value = FEntityNo;

			ElingOA6_DSJCJ.Model.Entity model=new ElingOA6_DSJCJ.Model.Entity();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["FEntityNo"]!=null && ds.Tables[0].Rows[0]["FEntityNo"].ToString()!="")
				{
					model.FEntityNo=ds.Tables[0].Rows[0]["FEntityNo"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FEntityName"]!=null && ds.Tables[0].Rows[0]["FEntityName"].ToString()!="")
				{
					model.FEntityName=ds.Tables[0].Rows[0]["FEntityName"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FLeader"]!=null && ds.Tables[0].Rows[0]["FLeader"].ToString()!="")
				{
					model.FLeader=ds.Tables[0].Rows[0]["FLeader"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FShortName"]!=null && ds.Tables[0].Rows[0]["FShortName"].ToString()!="")
				{
					model.FShortName=ds.Tables[0].Rows[0]["FShortName"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FAccessDate"]!=null && ds.Tables[0].Rows[0]["FAccessDate"].ToString()!="")
				{
					model.FAccessDate=DateTime.Parse(ds.Tables[0].Rows[0]["FAccessDate"].ToString());
				}
				if(ds.Tables[0].Rows[0]["FLastLoginIPAddr"]!=null && ds.Tables[0].Rows[0]["FLastLoginIPAddr"].ToString()!="")
				{
					model.FLastLoginIPAddr=ds.Tables[0].Rows[0]["FLastLoginIPAddr"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FLogID"]!=null && ds.Tables[0].Rows[0]["FLogID"].ToString()!="")
				{
					model.FLogID=ds.Tables[0].Rows[0]["FLogID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["fuseTimes"]!=null && ds.Tables[0].Rows[0]["fuseTimes"].ToString()!="")
				{
					model.fuseTimes=int.Parse(ds.Tables[0].Rows[0]["fuseTimes"].ToString());
				}
				if(ds.Tables[0].Rows[0]["FPublishRoot"]!=null && ds.Tables[0].Rows[0]["FPublishRoot"].ToString()!="")
				{
					model.FPublishRoot=ds.Tables[0].Rows[0]["FPublishRoot"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FWaterMarkContent"]!=null && ds.Tables[0].Rows[0]["FWaterMarkContent"].ToString()!="")
				{
					model.FWaterMarkContent=(byte[])ds.Tables[0].Rows[0]["FWaterMarkContent"];
				}
				if(ds.Tables[0].Rows[0]["FWaterMarkSvrFileName"]!=null && ds.Tables[0].Rows[0]["FWaterMarkSvrFileName"].ToString()!="")
				{
					model.FWaterMarkSvrFileName=ds.Tables[0].Rows[0]["FWaterMarkSvrFileName"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FWaterMarkExt"]!=null && ds.Tables[0].Rows[0]["FWaterMarkExt"].ToString()!="")
				{
					model.FWaterMarkExt=ds.Tables[0].Rows[0]["FWaterMarkExt"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FWaterMarkOldFileName"]!=null && ds.Tables[0].Rows[0]["FWaterMarkOldFileName"].ToString()!="")
				{
					model.FWaterMarkOldFileName=ds.Tables[0].Rows[0]["FWaterMarkOldFileName"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FWebBeiAnNo"]!=null && ds.Tables[0].Rows[0]["FWebBeiAnNo"].ToString()!="")
				{
					model.FWebBeiAnNo=ds.Tables[0].Rows[0]["FWebBeiAnNo"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FCopyRight"]!=null && ds.Tables[0].Rows[0]["FCopyRight"].ToString()!="")
				{
					model.FCopyRight=ds.Tables[0].Rows[0]["FCopyRight"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FTxtWaterMark"]!=null && ds.Tables[0].Rows[0]["FTxtWaterMark"].ToString()!="")
				{
					model.FTxtWaterMark=ds.Tables[0].Rows[0]["FTxtWaterMark"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FSmtpHost"]!=null && ds.Tables[0].Rows[0]["FSmtpHost"].ToString()!="")
				{
					model.FSmtpHost=ds.Tables[0].Rows[0]["FSmtpHost"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FSmtpAccount"]!=null && ds.Tables[0].Rows[0]["FSmtpAccount"].ToString()!="")
				{
					model.FSmtpAccount=ds.Tables[0].Rows[0]["FSmtpAccount"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FSmtpPassword"]!=null && ds.Tables[0].Rows[0]["FSmtpPassword"].ToString()!="")
				{
					model.FSmtpPassword=ds.Tables[0].Rows[0]["FSmtpPassword"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FWaterMarkCls"]!=null && ds.Tables[0].Rows[0]["FWaterMarkCls"].ToString()!="")
				{
					model.FWaterMarkCls=ds.Tables[0].Rows[0]["FWaterMarkCls"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FSmtpPort"]!=null && ds.Tables[0].Rows[0]["FSmtpPort"].ToString()!="")
				{
					model.FSmtpPort=int.Parse(ds.Tables[0].Rows[0]["FSmtpPort"].ToString());
				}
				if(ds.Tables[0].Rows[0]["FIsSsl"]!=null && ds.Tables[0].Rows[0]["FIsSsl"].ToString()!="")
				{
					model.FIsSsl=decimal.Parse(ds.Tables[0].Rows[0]["FIsSsl"].ToString());
				}
				if(ds.Tables[0].Rows[0]["FFlowLockTime"]!=null && ds.Tables[0].Rows[0]["FFlowLockTime"].ToString()!="")
				{
					model.FFlowLockTime=int.Parse(ds.Tables[0].Rows[0]["FFlowLockTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["FIsIPControl"]!=null && ds.Tables[0].Rows[0]["FIsIPControl"].ToString()!="")
				{
					model.FIsIPControl=ds.Tables[0].Rows[0]["FIsIPControl"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FNTKOCaption"]!=null && ds.Tables[0].Rows[0]["FNTKOCaption"].ToString()!="")
				{
					model.FNTKOCaption=ds.Tables[0].Rows[0]["FNTKOCaption"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FNTKOKey"]!=null && ds.Tables[0].Rows[0]["FNTKOKey"].ToString()!="")
				{
					model.FNTKOKey=ds.Tables[0].Rows[0]["FNTKOKey"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FSysCopyRight"]!=null && ds.Tables[0].Rows[0]["FSysCopyRight"].ToString()!="")
				{
					model.FSysCopyRight=ds.Tables[0].Rows[0]["FSysCopyRight"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FSysTitle"]!=null && ds.Tables[0].Rows[0]["FSysTitle"].ToString()!="")
				{
					model.FSysTitle=ds.Tables[0].Rows[0]["FSysTitle"].ToString();
				}
				return model;
			}
			else
			{
				return null;
			}
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
            strSql.Append("select FEntityNo,FEntityName,FLeader,FShortName,FAccessDate,FLastLoginIPAddr,FLogID,fuseTimes,FPublishRoot,FWaterMarkContent,FWaterMarkSvrFileName,FWaterMarkExt,FWaterMarkOldFileName,FWebBeiAnNo,FCopyRight,FTxtWaterMark,FSmtpHost,FSmtpAccount,FSmtpPassword,FWaterMarkCls,FSmtpPort,FIsSsl,FFlowLockTime,FIsIPControl,FNTKOCaption,FNTKOKey,FSysCopyRight,FSysTitle,FFtpShowText ");
			strSql.Append(" FROM t_Entity ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
			strSql.Append(" FEntityNo,FEntityName,FLeader,FShortName,FAccessDate,FLastLoginIPAddr,FLogID,fuseTimes,FPublishRoot,FWaterMarkContent,FWaterMarkSvrFileName,FWaterMarkExt,FWaterMarkOldFileName,FWebBeiAnNo,FCopyRight,FTxtWaterMark,FSmtpHost,FSmtpAccount,FSmtpPassword,FWaterMarkCls,FSmtpPort,FIsSsl,FFlowLockTime,FIsIPControl,FNTKOCaption,FNTKOKey,FSysCopyRight,FSysTitle ");
			strSql.Append(" FROM t_Entity ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM t_Entity ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.FEntityNo desc");
			}
			strSql.Append(")AS Row, T.*  from t_Entity T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "t_Entity";
			parameters[1].Value = "FEntityNo";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  Method


        #region 增加的方法

        /// <summary>
        /// 获取系统标题
        /// <creator>rend</creator>
        /// <date>2013-2-5</date>
        /// </summary>
        /// <param name="entityNo"></param>
        /// <returns></returns>
        public string GetSysTitle(string entityNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 FSysTitle from t_Entity");
            strSql.Append(" where FEntityNo=@FEntityNo");

            SqlParameter[] parameters = { 
                    new SqlParameter("@FEntityNo", SqlDbType.NVarChar, 15) };
            parameters[0].Value = entityNo;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (null != obj)
            {
                return obj.ToString();
            }
            else {
                return string.Empty;
            }
        }



        /// <summary>
        /// 获取权属说明
        /// <creator>rend</creator>
        /// <date>2013-2-5</date>
        /// </summary>
        /// <param name="entityNO"></param>
        /// <returns></returns>
        public string GetCopyRight(string entityNO)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top 1 FCopyRight from t_Entity");
            strSql.Append(" where FEntityNo=@FEntityNo");

            SqlParameter[] parameters = { 
                    new SqlParameter("@FEntityNo", SqlDbType.NVarChar, 15) };
            parameters[0].Value = entityNO;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (null != obj)
            {
                return obj.ToString();
            }
            else
            {
                return string.Empty;
            }
        }
        
        /// <summary>
        ///  更新有关最近登录等相关的信息
        /// <creator>rend</creator>
        /// <date>2013-2-6</date>
        /// </summary>
        /// <param name="model"></param>
        public void UpdateByEntityNo(Model.Entity model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update t_Entity set ");
            strSql.Append("FAccessDate=@FAccessDate,");
            strSql.Append("FLastLoginIPAddr=@FLastLoginIPAddr,");
            strSql.Append("FLogID=@FLogID");
            strSql.Append(" where FEntityNo=@FEntityNo");
            SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.VarChar,15),					
					new SqlParameter("@FAccessDate", SqlDbType.DateTime),					
					new SqlParameter("@FLastLoginIPAddr", SqlDbType.VarChar,15),
					new SqlParameter("@FLogID", SqlDbType.VarChar,30)};

            parameters[0].Value = model.FEntityNo;
            parameters[1].Value = model.FAccessDate;
            parameters[2].Value = model.FLastLoginIPAddr;
            parameters[3].Value = model.FLogID;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }




        /// <summary>
        /// 判断该用户某个时间段是否登录过,用于表t_EmpSignTime
        /// <creator>rend</creator>
        /// <date>2013-03-14</date>
        /// </summary>
        /// <param name="emplNo"></param>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public bool ExistsSignTime(string emplNo, string beginTime, string endTime)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from t_EmpSignTime");
            strSql.Append(" where FEmplNo=@FEmplNo and datediff(DAY,'");
            strSql.Append(beginTime);
            strSql.Append("',FSign_time)>=0 and datediff(DAY,'");
            strSql.Append(endTime);
            strSql.Append("',FSign_time)<=0");
            SqlParameter[] parameters = {
					new SqlParameter("@FEmplNo", SqlDbType.NVarChar,15)};
            parameters[0].Value = emplNo;
            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }



        /// <summary>
        ///  增加一条签到,用于表t_EmpSignTime
        /// <creator>rend</creator>
        /// <date>2013-03-14</date>
        /// </summary>
        /// <param name="empNO"></param>
        /// <param name="time"></param>
        public void AddSignTime(string empNO,DateTime time)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into t_EmpSignTime(");
            strSql.Append("FEmplNo,FSign_time)");
            strSql.Append(" values (");
            strSql.Append("@FEmplNo,@FSign_time)");
            SqlParameter[] parameters = {
					new SqlParameter("@FEmplNo", SqlDbType.NVarChar,15),
					new SqlParameter("@FSign_time", SqlDbType.DateTime)};
            parameters[0].Value = empNO;
            parameters[1].Value = time;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 获取绩效考核最大年度
        /// <creator>rend</creator>
        /// <date>2013-03-14</date>
        /// </summary>
        /// <param name="FEntityNo"></param>
        /// <returns></returns>
        public string GetCxcsEvlaClassMaxYear(string FEntityNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT max(fyear) FROM t_cxcsEvalClass ");
            strSql.Append("WHERE FEntityNo =@FEntityNo");
            SqlParameter[] parameters = {
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,15)};

            parameters[0].Value = FEntityNo;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (null != obj)
            {
                return obj.ToString();
            }
            else
            {
                return DateTime.Now.Year.ToString();
            }

        }


        /// <summary>
        /// 获取政府采购当前年度
        /// <creator>rend</creator>
        /// <date>2013-03-14</date>
        /// </summary>
        /// <param name="strEntityNo"></param>
        /// <returns></returns>
        public int GetGovYear(string strEntityNo)
        {
            StringBuilder strsql = new StringBuilder();
            strsql.Append("select FYear from t_purchaseYear");
            strsql.Append(" where fStatus='1' and FEntityNo=@FEntityNo");
            SqlParameter[] parameters = { 
                        new SqlParameter("@FEntityNo",SqlDbType.NVarChar,12)
                                        };
            parameters[0].Value = strEntityNo;
            object obj = DbHelperSQL.GetSingle(strsql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return int.Parse(obj.ToString());
            }
        }


        #endregion


    }
}